<template>
  <div class="containerx">
    <div class="body">
      <div class="left">
        <el-avatar
          size="large"
          src="https://cube.elemecdn.com/0/88/03b0d39583f48206768a7534e55bcpng.png"
          @click="gotouserinfo()"
        />
        <!-- 用户头像,点击跳转至个人空间 -->
      </div>
      <div class="right">
        <span class="username" @click="gotouserinfo()"> {{ username }}</span
        ><!-- 用户名,点击跳转至个人空间 -->
        <span class="posttime"> {{ posttime }}</span
        ><!-- 发表时间 -->
        <div class="content-body">
          <p style="font-size: 20px">
            <!-- Additional text content -->
            文字区域*********************文字区域**************{{ text }}
          </p>
          <div class="image-container">
            <!-- Display up to 6 images here -->
            <el-image
              v-for="(image, index) in images"
              :key="index"
              :src="image.src"
              :fit="fit"
              :preview-src-list="srcList"
              :initial-index="index"
            />
          </div>
        </div>
      </div>
    </div>
    <div class="footer">
      <div><i class="iconfont iconshoucang"></i>收藏</div>
      <div @click="togglecommentshowflag()">
        <!-- 点击切换评论框显示标志 -->
        <i class="iconfont iconpinglun"></i>评论{{}}
      </div>
      <div><i class="iconfont iconziyuan"></i>赞{{}}</div>
    </div>
    <div v-if="commentshowflag" class="commentbody">
      <!-- 评论框显示标志为真时显示评论框 -->
      <div class="writecomment">
        <!--写评论-->
        <div class="wctop">
          <div>
            <input v-model="commenttext" type="text" />
          </div>
        </div>
        <div class="wcbottom">
          <div @click="postcomment()">评论</div>
        </div>
      </div>
      <Comment
        v-for="(commentinfo, index) in commentslist"
        :key="index"
        :commentinfo="commentinfo"
      /><!-- 加载评论列表 -->
    </div>
  </div>
</template>
<script>
import { ref } from "vue";
export default {
  setup() {
    const url =
      "https://fuss10.elemecdn.com/e/5d/4a731a90594a4af544c0c25941171jpeg.jpeg"; //测试用图片url
    const images = ref([
      {
        src: "https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg",
      },
      {
        src: "https://fuss10.elemecdn.com/1/34/19aa98b1fcb2781c4fba33d850549jpeg.jpeg",
      },
      {
        src: "https://fuss10.elemecdn.com/0/6f/e35ff375812e6b0020b6b4e8f9583jpeg.jpeg",
      },
      {
        src: "https://fuss10.elemecdn.com/9/bb/e27858e973f5d7d3904835f46abbdjpeg.jpeg",
      },
      {
        src: "https://fuss10.elemecdn.com/d/e6/c4d93a3805b3ce3f323f7974e6f78jpeg.jpeg",
      },
      {
        src: "https://fuss10.elemecdn.com/2/11/6535bcfb26e4c79b48ddde44f4b6fjpeg.jpeg",
      },
      // Add more image URLs here
    ]);
    const srcList = [
      "https://fuss10.elemecdn.com/a/3f/3302e58f9a181d2509f3dc0fa68b0jpeg.jpeg",
      "https://fuss10.elemecdn.com/1/34/19aa98b1fcb2781c4fba33d850549jpeg.jpeg",
      "https://fuss10.elemecdn.com/0/6f/e35ff375812e6b0020b6b4e8f9583jpeg.jpeg",
      "https://fuss10.elemecdn.com/9/bb/e27858e973f5d7d3904835f46abbdjpeg.jpeg",
      "https://fuss10.elemecdn.com/d/e6/c4d93a3805b3ce3f323f7974e6f78jpeg.jpeg",
      "https://fuss10.elemecdn.com/3/28/bbf893f792f03a54408b3b7a7ebf0jpeg.jpeg",
      "https://fuss10.elemecdn.com/2/11/6535bcfb26e4c79b48ddde44f4b6fjpeg.jpeg",
    ];

    const username = ref("Flyyy"); //用户名
    const posttime = ref("2021-10-10 10:10:10"); //发表时间
    const commentshowflag = ref(false); //评论框显示标志
    const commenttext = ref(""); //评论框内容
    const commentslist = ref([]); //评论列表
    const gotouserinfo = () => {}; //跳转到用户信息页
    const togglecommentshowflag = () => {}; //切换评论框显示标志
    const postcomment = () => {}; //发表评论
    return {
      url,
      srcList,
      images,
      username,
      commentshowflag,
      commenttext,
      commentslist,
      gotouserinfo,
      togglecommentshowflag,
      postcomment,
      posttime,
    };
  },
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.containerx {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  background-color: rgba(255, 255, 255, 1);
  background-image: none;
  border-radius: 5px;
  margin-bottom: 10px;
  opacity: 1; /*透明度*/
  z-index: 2; /*层级*/
  border: green solid 1px; /* 边框 */
  box-shadow: 0 5px 10px -5px rgba(0, 0, 0, 0.2);
}
.body {
  width: 100%;
  display: flex;
  border-bottom: green solid 1px; /* 边框 */
  z-index: 1;
}
.body > .left {
  width: 4%;
  padding: 10px;
}
.body > .left > el-avatar {
  /* 用户头像 */
  width: 100%;
  border-radius: 50%;
  cursor: pointer;
}
.body > .right {
  width: 80%;
  display: flex;
  flex-direction: column;
  padding: 0 1px;
}
.body > .right > .username {
  font-size: 16px;
  padding: 5px 0;
}
.body > .right > .posttime {
  font-size: 10px;
  opacity: 0.4;
}
.body > .right > p {
  padding: 10px 0;
}
.body > .right > .username {
  width: 100%;
}
.footer {
  display: flex;
  width: 100%;
  justify-content: space-around;
}
.footer > div {
  margin: 10px 0;
  width: 30%;
  height: 20px;
  text-align: center;
  cursor: pointer;
  font-size: 10px;
  line-height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.footer > div:hover {
  color: rgb(226, 107, 52);
}
.footer > div > i {
  padding: 5px;
}
.footer > div:nth-child(1) {
  border-right: 1px solid rgba(0, 0, 0, 0.1);
}
.footer > div:nth-child(2) {
  border-right: 1px solid rgba(0, 0, 0, 0.1);
}
.commentbody {
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  width: 100%;
  display: flex;
  flex-direction: column;
  /* height: 300px; */
  padding: 20px;
}
.commentbody > .writecomment {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  padding-bottom: 10px;
}
.commentbody > .writecomment > .wctop {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-around;
}
.commentbody > .writecomment > .wctop > div {
  height: 30px;
  width: 100%;
  border: 1px solid rgba(0, 0, 0, 0.1);
  padding: 0 10px;
}
.commentbody > .writecomment > .wctop > div > input {
  width: 100%;
  height: 100%;
  outline: none;
}
.commentbody > .writecomment > .wcbottom {
  display: flex;
  flex-direction: row-reverse;
}
.commentbody > .writecomment > .wcbottom > div {
  /* width: 30px; */
  height: 25px;
  line-height: 25px;
  border-radius: 2px;
  background-color: rgb(250, 121, 55);
  margin-top: 10px;
  color: white;
  padding: 0 18px;
}

.el-image {
  width: 200px;
  height: 160px;
  padding: 0.3%;
  cursor: pointer; /* 鼠标移入变成小手 */
}
</style>
